#!/usr/bin/env node
var mysql = require('mysql');
var connection = mysql.createConnection({
    host : 'localhost',
    user : 'root',
    password : 'root',
    database : 'Test'
});
module.exports.connect = function(){   
    connection.connect(function(err){if (err) console.log(err)});
    console.log('Connected to Mysql');
    console.log('Connected to Test database');
}

module.exports.showTable = function(){
    connection.query('show table', function(rows){console.log(rows)});
   
}
module.exports.connection = connection;


module.exports.addUser = function(user){
    var username = user.username;
    var password = user.password;
    var q = "INSERT INTO `Customer` (`idCustomer`,`LoginName`,`Password`,`TrueName`,`Gender`,`Address`,`Postcode`,`Email`,`Phone`,`PswQuestion`,`PswAnswer`,`Account`) VALUES ('C000000001','Abel','lebA','Abel Tang','Male','Rua de Bruxelas edf Jardim Nam Ngon room G101 Macau','00853','dydeong@gmail.com','(00853)66669999','What''s my favority food?','Fish',10000.0);"
    var s = connection.query(q, error());
  //  console.log(s);
}

var error = function(error){if(error) throw error;};